<template>
	<el-dialog title="企业评级" v-model="visible" :width="400" destroy-on-close @closed="$emit('closed')">
		<el-form :model="form" :rules="rules" ref="dialogForm" label-width="100px" label-position="left">
			<el-form-item label="企业名称">{{form1.name}}
			</el-form-item>
			<el-form-item label="企业得分" prop="score">
				<el-input v-model="form.score" clearable type="number">
					<template #append>分</template>
				</el-input>
			</el-form-item>
			<el-form-item label="备注说明" prop="remark">
				<el-input v-model="form.remark" placeholder="备注说明" clearable maxlength="380" type="textarea"></el-input>
			</el-form-item>
		</el-form>
		<template #footer>
			<el-button @click="visible=false">取 消</el-button>
			<el-button v-if="mode!='show'" type="primary" :loading="isSaveing" @click="submit()">保 存</el-button>
		</template>
	</el-dialog>

</template>
<script>
export default {
	emits: ['success', 'closed'],
	components: {
	},
	data() {
		return {
			visible: false,
			isSaveing: false,
			mode: "add",
			templates: [],
			form1:{
				name:'',
			},
			form: {
				entId:'',
				remark:'',
				score:0
			},
			rules: {
				score:[
					{required: true, message: '企业得分不能为空', trigger: 'blur'}
				]
			}
		}
	},
	mounted() {
	},
	methods: {
		//显示
		open(mode = 'add') {
			this.mode = mode;
			this.visible = true;
			return this
		},
		submit() {
			this.$refs.dialogForm.validate(async (valid) => {
				if (valid) {
					this.isSaveing = true;
					var res = await this.$API.invite.inviteScore.setInviteScore.post(this.form);
					this.isSaveing = false;
					if (res.code == 200) {
						this.$emit('success')
						this.visible = false;
						this.$message.success("操作成功")
					} else {
						this.$alert(res.message, "提示", {type: 'error'})
					}
				}
			})
		},
		setData(data) {
			this.form.entId = data.entId
			this.form1.name = data.name
		},
	}
}
</script>
